package com.example.conference.mapper;

import com.example.conference.domain.Dept;
import com.example.conference.domain.DeptMajor;
import com.example.conference.domain.Major;
import com.example.conference.domain.vo.DeptMajorVo;
import com.example.conference.domain.vo.SelectVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeptMajorMapper {
    @Select("select * from major where major_id in (select major_id from dept_major where dept_id = #{deptId})")
    @Results(id= "MajorMap", value= {
            @Result(column="major_id", property="value" ),
            @Result(column="major_name", property="name" ),
    })
    List<SelectVo> queryByDeptIdToSelect(Integer deptId);

    @Results(id= "DeptMajorMap", value= {
            @Result(column="dept_id", property="value" ),
            @Result(column="dept_name", property="name" ),
            @Result(column="dept_id", property="majorList" ,
                    many=@Many(select="com.example.conference.mapper.DeptMajorMapper.queryByDeptIdToSelect"))
    })
    @Select("select * from dept")
    List<DeptMajorVo> queryAll();
}